package demo1;
class Animal {
    public String name;
    public int age;

    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println("小动物吃东西");
    }
}

class Dog extends Animal{
    public String color;

    public Dog(String name, int age, String color) {
        super(name, age);
        this.color = color;
    }

    public void eat() {
        System.out.println("小狗吃狗粮");
    }

    public void bark() {
        System.out.println("汪汪汪");
    }
}

public class Test {
    public static void func(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {
        Animal animal = new Dog("旺财",3,"黄色");
        animal.eat();
        func(animal);

    }
}
